<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta charset="utf-8">
	<title>收藏牛人</title>
	<meta name="keywords" content="">
	<meta name="description" content="">
	<meta name="author" content="">
	<link href="css/daterangepicker.min.css" rel="stylesheet">
	<link rel="stylesheet" href="css/main.css">
	<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!--[if lt IE 9]>
	<script src="js/html5shiv.min.js"></script>
	<script src="js/respond.min.js"></script>
<![endif]-->
<meta name="renderer" content="webkit">
<link rel="shortcut icon" href="favicon.ico">
<style>
	[v-cloak] {
		display: none!important;
	}
	.el-select {
		width: 270px;
	}

	.el-select input {
		height: 40px;

	}
</style>
</head>
<body>
<div id="app" v-cloak>
	<header>
	</header>
	<div class="header-space"></div>
	<section class="section291 style-blue">
		<div class="content">
			<div class="left">
				<div class="number">
					已收藏牛人：<i class="akrobat">{{summary.collect_count}}</i>人
				</div>
			</div>
			<div class="search">
				<input v-model="keyword" type="text" placeholder="请输入关键词" class="input" @change="searchHandle(1)" />
				<div class="line"></div>
				<select v-model="keywordType">
					<option v-for="item in keywordTypeList" :key="item.value" :value="item.value">{{item.label}}</option>
				</select>
				<div class="line"></div>
				<select v-model="topPosition" @change="searchHandle(1)">
					<option v-for="(item, index) in positionList" :key="index" :value="item.id">{{item.name}}</option>
				</select>
			</div>
		</div>
	</section>
	<section class="section292">
		<div class="content">
			<div class="filter">
				<div class="item">
					<p>期望职位</p>
					<div class="con">
						<select v-model="positionId">
							<option v-for="(item, index) in positionList" :key="index" :value="item.id">{{item.name}}</option>
						</select>
					</div>
				</div>
				<div class="item">
					<p>期望工作性质</p>
					<div class="con">
						<select v-model="natureId">
							<option v-for="(item, index) in natureList" :key="index" :value="item.id">{{item.name}}</option>
						</select>
					</div>
				</div>
				<div class="item">
					<p>求职地点</p>
					<div class="con">
						<select v-model="areaId">
							<option v-for="(item, index) in areaList" :key="index" :value="item.id">{{item.region_name}}</option>
						</select>
					</div>
				</div>
				<div class="item r">
					<p>期望薪资</p>
					<input v-model="min" type="text" class="input w125" placeholder="最低" />
					<span class="ml5">--</span>
					<input v-model="max" type="text" class="input w125 r" placeholder="最高" />
				</div>
				<div class="item">
					<p>学历</p>
					<div class="con">
						<select v-model="educationId">
							<option v-for="(item, index) in educationList" :key="index" :value="item.id">{{item.name}}</option>
						</select>
					</div>
				</div>
				<div class="item">
					<p>工作年限</p>
					<div class="con">
						<select v-model="expId">
							<option v-for="(item, index) in expList" :key="index" :value="item.id">{{item.min}}-{{item.max}}
							</option>
						</select>
					</div>
				</div>
				<div class="item">
					<p>性别</p>
					<div class="con">
						<select v-model="sexId">
							<option v-for="(item, index) in sexList" :key="index" :value="item.id">{{item.name}}</option>
						</select>
					</div>
				</div>
				<div class="item r">
					<p>工作状态</p>
					<div class="con">
						<select v-model="statusId">
							<option v-for="(item, index) in statusList" :key="index" :value="item.id">{{item.name}}</option>
						</select>
					</div>
				</div>
				<div class="item w586">
					<p>语种能力</p>
					<div class="con">
						<select v-model="languageId">
							<option v-for="(item, index) in languageList" :key="index" :value="item.id">{{item.name}}</option>
						</select>
					</div>
				</div>
				<div class="item w586 r">
					<p>毕业院校</p>
					<input v-model="school" type="text" class="input" placeholder="请输入院校名称关键字" />
				</div>
			</div>
			<div class="operate">
				<input type="submit" value="搜索" class="btn" @click="searchHandle">
				<input type="reset" value="清除" class="reset" @click="resetHandle">
			</div>
		</div>
	</section>
	<section class="section293 w1160">
		<div class="content">
			<div class="list-operate">
				<label for="" :class="{on: isCheckAll}" class="checkbox" @click="changeCheckAllHandle">全选</label>
				<span class="txt">当前页面简历数量 {{collectionList.length}} 份</span>
				<a href="javascript:void(0)" class="btn" @click="downLoadHandle">下载简历</a>
				<!-- <a v-show="tabIndex === 0" href="javascript:void(0)" class="btn btn-white" @click="interviewCheckHandle">发邀请</a> -->
			</div>
			<div class="list">
				<div v-for="(item, index) in collectionList" :key="item.id" class="item">
					<label for="" :class="{on: checkMap[index]}" class="checkbox" @click="changeCheckHandle(index)"></label>
					<div class="info">
						<div class="info-left">
							<div class="name"><a href="javascript:void(0)">{{item.user.name}}</a></div>
							<ul class="con">
								<li>{{item.user.sex|sexFilter}} | {{item.user.age}}岁 | {{item.education_experience.education}} |
									{{item.user.area}} | 3年 |
									{{item.resume.status}}</li>
								<li>电话：{{item.user.telephone || '暂无'}}</li>
								<li>邮箱：{{item.user.email}}</li>
								<li>期望职位：{{item.resume.title}}</li>
								<li>期望薪资：{{item.resume.salary}}</li>
								<li>工作地点/性质：{{item.resume.area}}/{{item.resume.nature}}</li>
								<li>毕业院校：{{item.education_experience.name}}</li>
								<li>语种能力：{{item.language}}</li>
								<li v-if="item.experience" class="w100">
									工作经验：{{item.experience.position}} | {{item.experience.time}}年 | {{item.experience.name}}
								</li>
								<li class="w100">
									个人标签：
									<span v-for="(tagItem) in item.tag" :key="tagItem.tag_id" class="tag">{{tagItem.name}}</span>
								</li>
								<li class="w100">
									自我评价：{{item.user.desc}}
								</li>
							</ul>
						</div>
						<div class="info-right">
							<div class="face">
								<a href="javascript:void(0)" @click="goResume(item.uid)"><img src="images/face.jpg" alt="" /></a>
							</div>
							<a href="javascript:void(0)" class="btn-hart" @click="collectHandle(index)"><img :src="'images/hart'+(item.is_collect?'-on': '')+'.png'" alt="" />{{item.is_collect?'取消': ''}}收藏</a>
						</div>
					</div>

					<!-- 待查看 -->
					<div class="bottom-operate">
						<div class="left">
							<h3>
								<b>职位：产品经理</b><span class="money">12~16k</span>
							</h3>
							<p>投递时间：2019-08-09 12:55</p>
						</div>
						<div class="operate">
							<!-- <a href="javascript:void(0)" class="btn btn-white" @click="unFitHandle(index, 2)">不合适</a> -->
							<a :href="'./39.html?id='+item.uid" class="btn btn-white">打招呼</a>
							<a href="javascript:void(0)" class="btn" @click="interviewHandle(index, 0)">邀面试</a>
						</div>
					</div>
					<!-- /待查看 -->

					<!-- 待接受 -->
					<!-- <div v-if="currentTab.type == 6" class="bottom-operate">
						<div class="left">
							<div class="status blue">等待对方接受面试邀请</div>
							<ul class="con">
								<li class="w100">邀请时间：2019-08-09 12:55</li>
								<li>面试职位：产品经理</li>
								<li class="w66">面试时间：{{item.time}}</li>
								<li>面试人： {{item.name}}</li>
								<li class="w66">联系方式：{{item.tel}}</li>
								<li class="w100">
									面试地点：北京市海淀区泰祥大厦 15 号楼 3 单 303
								</li>
								<li class="w100">面试备注：{{item.remark}}</li>
							</ul>
						</div>
						<div class="operate">
							<a href="javascript:void(0)" class="btn btn-white" @click="unFitHandle(index, 2)">不合适</a>
							<a :href="'./39.html?id='+item.uid" class="btn btn-white">打招呼</a>
							<a href="javascript:void(0)" class="btn" @click="interviewHandle(index, 0)">邀面试</a>
						</div>
					</div> -->
					<!-- /待接受 -->

					<!-- 待面试 -->
					<!-- <div v-if="currentTab.type == 7" class="bottom-operate">
						<div class="left">
							<div class="status blue">等待对方接受面试邀请</div>
							<ul class="con">
								<li class="w100">邀请时间：2019-08-09 12:55</li>
								<li>面试职位：产品经理</li>
								<li class="w66">面试时间：{{item.time}}</li>
								<li>面试人： {{item.name}}</li>
								<li class="w66">联系方式：{{item.tel}}</li>
								<li class="w100">
									面试地点：北京市海淀区泰祥大厦 15 号楼 3 单 303
								</li>
								<li class="w100">面试备注：{{item.remark}}</li>
							</ul>
						</div>
						<div class="operate">
							<a href="javascript:void(0)" class="btn btn-white" @click="overHandle(index)">面试结束</a>
							<a href="javascript:void(0)" class="btn btn-white" @click="unFitHandle(index, 1)">取消面试</a>
							<a href="javascript:void(0)" class="btn btn-white" @click="interviewHandle(index, 1)">编辑</a>
							<a :href="'./39.html?id='+item.uid" class="btn">打招呼</a>
						</div>
					</div> -->
					<!-- /待面试 -->
					<!-- 被拒绝 -->

					<!-- <div v-if="currentTab.type == 8" class="bottom-operate">
						<div class="left">
							<div class="status orange">
								对方拒绝面试邀请 <small>拒绝原因：{{item.reason}}</small>
							</div>

							<ul class="con">
								<li class="w100">拒绝时间：2019-08-09 12:55</li>
								<li>面试职位：产品经理</li>
								<li class="w66">面试时间：{{item.time}}</li>
								<li>面试人： {{item.name}}</li>
								<li class="w66">联系方式：{{item.tel}}</li>
								<li class="w100">
									面试地点：北京市海淀区泰祥大厦 15 号楼 3 单 303
								</li>
								<li class="w100">面试备注：{{item.remark}}</li>
							</ul>
						</div>
						<div class="operate">
							<a :href="'./39.html?id='+item.uid" class="btn">打招呼</a>
						</div>
					</div> -->
					<!-- /被拒绝 -->
					<!-- 不合适 -->
					<!-- <div v-if="currentTab.type == 3" class="bottom-operate">
						<div class="left">
							<div class="status orange">
								不合适
								<small>原因描述：{{item.reason}}</small>
							</div>

							<ul class="con">
								<li class="w100">操作时间：2019-08-09 12:55</li>
								<li>面试职位：产品经理</li>
								<li class="w66">面试时间：{{item.time}}</li>
								<li>面试人： {{item.name}}</li>
								<li class="w66">联系方式：{{item.tel}}</li>
								<li class="w100">
									面试地点：北京市海淀区泰祥大厦 15 号楼 3 单 303
								</li>
								<li class="w100">面试备注：{{item.remark}}</li>
							</ul>
						</div>
						<div class="operate">
							<a :href="'./39.html?id='+item.uid" class="btn">打招呼</a>
						</div>
					</div> -->
					<!-- /不合适 -->
					<!-- 未录用 -->
					<!-- <div v-if="currentTab.type == 4" class="bottom-operate">
						<div class="left">
							<div v-if="item.evaluate" class="status blue">
								企业点评： <small>{{item.evaluate}}</small>
							</div>
							<div v-else class="status orange">
								<a href="javascript:void(0)" class="blue arrow" @click="evalHandle(index)">去点评</a>
							</div>

							<ul class=" con">
								<li class="w100">操作时间：2019-08-09 12:55</li>
								<li>面试职位：产品经理</li>
								<li class="w66">面试时间：{{item.time}}</li>
								<li>面试人： {{item.name}}</li>
								<li class="w66">联系方式：{{item.tel}}</li>
								<li class="w100">
									面试地点：北京市海淀区泰祥大厦 15 号楼 3 单 303
								</li>
								<li class="w100">面试备注：{{item.remark}}</li>
							</ul>
						</div>
						<div class="operate">
							<a :href="'./39.html?id='+item.uid" class="btn">打招呼</a>
						</div>
					</div> -->
					<!-- /未录用 -->
					<!-- 已录用 -->
					<!-- <div v-if="currentTab.type == 5" class="bottom-operate">
						<div class="left">
							<div v-if="item.evaluate" class="status blue">
								企业点评： <small>{{item.evaluate}}</small>
							</div>
							<div v-else class="status orange">
								<a href="javascript:void(0)" class="blue arrow" @click="evalHandle(index)">去点评</a>
							</div>

							<ul class="con">
								<li class="w100">操作时间：2019-08-09 12:55</li>
								<li>面试职位：产品经理</li>
								<li class="w66">面试时间：{{item.time}}</li>
								<li>面试人： {{item.name}}</li>
								<li class="w66">联系方式：{{item.tel}}</li>
								<li class="w100">
									面试地点：北京市海淀区泰祥大厦 15 号楼 3 单 303
								</li>
								<li class="w100">面试备注：{{item.remark}}</li>
							</ul>
						</div>
						<div class="operate">
							<a :href="'./39.html?id='+item.uid" class="btn">打招呼</a>
						</div>
					</div> -->
					<!-- /已录用 -->
				</div>
			</div>

			<div class="g-prvNxt" v-if="collectionList.length > 0">
				<el-pagination background layout="prev, pager, next, jumper" :total="total" :current-page.sync="page" :page-size="15" @current-change="getListData">
				</el-pagination>
			</div>
		</div>
	</section>

	<pop-reason v-if="isShowReason" :id="editId" :type="editType" @cancel="cancelHandle" @sure="sureHandle">
	</pop-reason>
	<pop-interview v-if="isShowIterview" :id="editId" :type="editType" :uid="editUid" @cancel="cancelHandle" @sure="sureHandle"></pop-interview>

	<el-dialog title="面试结束" :visible.sync="isShowDialog" width="30%">
		<span>是否录用</span>
		<span slot="footer" class="dialog-footer">
			<el-button @click="changeInterviewResult(3)">未录用</el-button>
			<el-button type="primary" @click="changeInterviewResult(4)">已录用</el-button>
		</span>
	</el-dialog>

	<footer id="footer"></footer>
</div>	
<script src="js/jquery.min.js"></script>
<script src="js/slide.min.js"></script>
<script src="js/polyfill.min.js"></script>
<script src="js/jquery.nicescroll3.7.6.min.js"></script>
<script src="js/main.js"></script>
<script src="js/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="js/request.js"></script>
<script src="js/getPrepareData.js"></script>
<script src="js/popComponents.js"></script>
<script>
	$(function(){
		$("header").load("./enterpriseCommon/header.html");
		$("#footer").load("./enterpriseCommon/footer.html");
	})
</script>
<script>
	var vm = new Vue({
		el: "#app",
		data: function() {
			return {
				summary: {
					collect_count: 0
				},
				page: 1,
				total: 0,
				collectionList: [],
				keyword: '',
				keywordType: 'name',
				keywordTypeList: [{
					value: 'name',
					label: '姓名'
				}, {
					value: 'age',
					label: '年龄'
				}, {
					value: 'tag',
					label: '标签'
				}],
				topPosition: '',
				positionList: [],
				positionId: '',
				natureList: [],
				natureId: '',
				areaList: [],
				areaId: '',
				educationList: [],
				educationId: '',
				expList: [],
				expId: '',
				sexList: [{
					id: 0,
					name: '女'
				}, {
					id: 1,
					name: '男'
				}],
				sexId: '',
				statusList: [],
				statusId: '',
				languageList: [],
				languageId: '',
				school: '',
				min: '',
				max: '',
				checkMap: {},
				isShowReason: false,
				isShowIterview: false,
				isShowDialog: false,
				editIndex: 0, // 正在操作的简历的列表项索引
				editType: 0, // 0添加 ，取消面试, 1编辑面试
				editId: 0, // 编辑等操作时的id
				editUid: 0 // 编辑等操作是用户的id
			};
		},
		computed: {
			editItem: function() {
				return this.collectionList[this.editIndex] || {}
			},
			checkCount: function() {
				var checkMap = this.checkMap
				return Object.keys(checkMap).reduce(function(count, key) {
					if (checkMap[key]) count++
					return count
				}, 0)
			},
			isCheckAll: {
				get: function() {
					var checkMap = this.checkMap;
					var checkCount = this.checkCount;
					return checkCount && Object.keys(checkMap).every(function(key) {
						return checkMap[key]
					})
				},
				set: function(bool) {
					var checkMap = this.checkMap;
					Object.keys(checkMap).forEach(function(key) {
						checkMap[key] = bool
					})
				}
			}
		},
		created: function() {
			var self = this;
			prepare.getEnterPriseResumeData(function(data) {
				self.setPrepare(data);
				self.getListData();
				self.getSummary();
			})
		},
		methods: {
			sureHandle: function() {
				this.getListData();
				this.cancelHandle();
			},
			// 不合适,取消面试
			unFitHandle: function(index, type) {
				this.editIndex = index;
				var item = this.editItem;
				this.isShowReason = true;
				this.editType = type;
				this.editId = item.id;
			},
			// 邀请面试，编辑面试
			interviewHandle: function(index, type) {
				this.editIndex = index;
				var item = this.editItem;
				this.isShowIterview = true;
				this.editType = type;
				this.editUid = item.uid;

				this.editId = type === 1 ? item.id : item.recruit_id;
			},
			// 下载简历
			downLoadHandle: function() {

				var checkCount = this.checkCount;
				var checkMap = this.checkMap;
				var currentList = this.collectionList;
				if (!checkCount) return;
				this.$message('功能暂未开放')
			},
			evalHandle: function(index) {
				this.editIndex = index;
				var item = this.editItem;
				if (item.resume.id === undefined) {
					return this.$message('暂无简历')
				}

				var self = this;
				this.$prompt('请输入点评内容', '点评', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
				}).then(function(prompRes) {
					var value = prompRes.value;
					request('enterprise/resume_comment', 'POST', JSON.stringify({
						resume_id: item.resume.id,
						content: value
					}), function(res) {
						self.$message.success('点评成功')
						item.evalute = value
					})
				}).catch(function(err) {

				});
			},
			// 邀请选中
			interviewCheckHandle: function() {
				var checkCount = this.checkCount;
				var checkMap = this.checkMap;
				var currentList = this.collectionList;
				console.log(checkCount);
				if (!checkCount) return;
				this.editUid = Object.keys(checkMap).filter(function(key) {
					return checkMap[key]
				}).map(function(key) {
					var item = currentList[key]
					return item.uid;
				})
				this.editType = 0;
				this.isShowIterview = true;

			},
			// 面试结束
			overHandle: function(index) {
				this.editIndex = index;
				var item = this.editItem;
				this.isShowIterview = true;
				this.editId = item.id;
			},
			// 面试结束，确定面试结果
			changeInterviewResult: function(status) {
				var self = this;
				request('enterprise/user_recruit/' + this.editId, 'PUT', JSON.stringify({
					id: this.editId,
					status: statsu
				}), function(res) {
					self.$message({
						type: 'success',
						message: res.message
					});
					self.collectionList.splice(self.editIndex, 1);
					self.isShowDialog = false
				}, function(err) {
					var msg = err.responseJSON ? err.responseJSON.message : '操作失败'
					self.$message({
						type: 'warning',
						message: msg
					})
					self.isShowDialog = false
				})
			},
			// 关闭弹窗
			cancelHandle: function() {
				this.isShowDialog = this.isShowIterview = this.isShowReason = false;
			},
			// 全选
			changeCheckAllHandle: function() {
				this.isCheckAll = !this.isCheckAll
			},
			// 切换单项选中
			changeCheckHandle: function(index) {
				var checkMap = this.checkMap;
				checkMap[index] = !checkMap[index];
			},
			// 搜索
			searchHandle: function(type) {
				this.getListData(type === 1);
			},
			// 重置
			resetHandle: function() {
				this.natureId = '';
				this.areaId = '';
				this.statusId = '';
				this.positionId = '';
				this.educationId = '';
				this.languageId = '';
				this.school = '';
				this.min = '';
				this.max = '';
				this.sexId = '';
				this.expId = '';
				this.getListData()
			},
			// 设置准备（头部）信息
			setPrepare: function(data) {
				var map = {
					nature: 'natureList',
					position: 'positionList',
					education: 'educationList',
					status: 'statusList',
					language: 'languageList',
					experience: 'expList',
					region: 'areaList',
				}
				for (var key in map) {
					this[map[key]] = data[key] || []
				}
			},
			collectHandle: function(index) {
				this.editIndex = index;
				var item = this.editItem;
				request('enterprise/resume/collect', item.is_collect ? 'DELETE' : 'POST', JSON.stringify({
					user_id: item.uid
				}), success.bind(this))

				function success(res) {
					this.$message.success(res.message)
					this.$set(item, 'is_collect', !item.is_collect)
				}
			},
			// 查看简历
			goResume: function(id) {
				if (id !== undefined) {
					location.href = "./30.html?id=" + id;
				} else {
					this.$message('暂无简历');
				}
			},
			getSummary: function() {
				request('enterprise/index/summary', 'GET', {
					page: 'index'
				}, function(res) {
					this.summary = res.data;
				})
			},
			// 获取简历列表
			getListData: function(type) {
				var params = {
					page: this.page
				};
				if (type) {
					params.positon_id = this.topPosition;
					params[this.keywordType] = this.keyword;
				} else {
					params.nature_id = this.natureId;
					params.area_id = this.areaId;
					params.status_id = this.statusId;
					params.position_id = this.positionId;
					params.education_id = this.educationId;
					params.language_id = this.languageId;
					params.school = this.school;
					params.salary = this.max;
					params.sex = this.sexId;
					params.experience_config_id = this.expId;
				}
				Object.keys(params).forEach(function(key) {
					if (params[key] === '') delete params[key]
				})
				request(
					"enterprise/resume/list",
					"GET", params,
					success.bind(this),
					fail.bind(this)
				);

				function success(res) {
					var data = res.data;
					var list = data.list;
					var checkMap = {};
					list.forEach(function(item, index) {
						checkMap[index] = false;
						var user = item.user;
						var resume = item.resume;
						var experience = item.experience = item.experience.slice(-1)[0];
						var e_x = item.education_experience = item.education_experience.slice(-1)[0]
						if (user) {
							user.age = new Date().getFullYear() - new Date(user.birthday).getFullYear() || 0;
							user.area = prepare.getRegionNameList(user.area_id || 1).slice(-1)[0];
						} else {
							item.user = {
								sex: 1,
								name: '姓名',
								age: 0,
								telephone: '暂无',
								email: '暂无',
								telephone: '暂无',
								area: '暂无'
							}
						}

						if (resume) {
							// resume.positon = prepare.getPositionNameList(resume.position_id).slice(-1)[0];
							resume.area = prepare.getRegionNameList(resume.area_id || 1).slice(-1)[0];
							resume.status = prepare.getStatusName(resume.status_id);
							resume.nature = prepare.getNatureName(resume.nature_id);
							resume.salary = item.resume.salary_min + '-' + item.resume.salary_max + 'k'
						} else {
							item.resume = {
								position: "暂无简历",
								area: "暂无简历",
								status: "暂无简历",
								nature: "暂无简历",
								salary: "暂无简历",
							}
						}

						if (experience) {
							experience.time = new Date(/\d/.test(experience.end) ? experience.end : Date.now()).getFullYear() - new Date(experience.start).getFullYear();
						}
						if (e_x) {
							e_x.education = prepare.getEducationName(e_x.education_id);
						} else {
							item.education_experience = {
								education: '暂无',
								name: '暂无',
							}
						}
						item.tag.forEach(function(tagItem) {
							tagItem.name = prepare.getTagName(tagItem.tag_id);
						});
						item.language = item.language.map(function(languageItem) {
							var language = prepare.getLanguageName(languageItem.language_id);
							var ability = prepare.getAbilityName(languageItem.ability_id)
							return language ? language + '|' + ability : '暂无'
						}).join(',');
					})
					this.checkMap = checkMap;
					this.$set(this.collectionList, this.page, list);
					this.total = data.total;
				}
				function fail(err) {
					console.log(err);
				}
			}
		},
		filters: {
			sexFilter: function(sex) {
				return ['女', '男'][sex]
			}
		}
	});

</script>
</body>
</html>